﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;

namespace DataSimFinancial.Duffy.BusinessLogic
{
    public class DataLayer
    {
        // Constructor
        public DataLayer()
        {
            

        }

        public static DataTable Getdata()
        {
            string connString;
            connString = ConfigurationManager.ConnectionStrings["MyDBConnectionString"].ToString();

            // Sql Connection
            SqlConnection conn = new SqlConnection();
            conn.ConnectionString = connString;


            // Sql Command
            string query = "Select * from Asset_Price";
            SqlCommand sqlComm = new SqlCommand(query, conn);
            sqlComm.CommandTimeout = 300;

            // SqlAdapter
            SqlDataAdapter stockpricesDA = new SqlDataAdapter();
            stockpricesDA.SelectCommand = sqlComm;

            conn.Open();

            // DataSet
            DataTable stockDT = new DataTable();
            stockpricesDA.Fill(stockDT);

            // Close Connection
            conn.Close();


            return stockDT;


        }

    }
}
